<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>每日任务追踪器</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
        }

        .container {
            width: 100%;
            max-width: 800px;
            background-color: rgba(255, 255, 255, 0.95);
            border-radius: 20px;
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
            overflow: hidden;
        }

        .header {
            background: linear-gradient(to right, #4776E6, #8E54E9);
            color: white;
            padding: 30px;
            text-align: center;
            position: relative;
        }

        .header h1 {
            font-size: 2.5rem;
            margin-bottom: 10px;
            font-weight: 700;
        }

        .header p {
            font-size: 1.1rem;
            opacity: 0.9;
        }

        .progress-container {
            background-color: #f0f0f0;
            padding: 20px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            border-bottom: 1px solid #e0e0e0;
        }

        .progress-bar {
            flex-grow: 1;
            height: 20px;
            background-color: #e0e0e0;
            border-radius: 10px;
            margin: 0 15px;
            overflow: hidden;
            position: relative;
        }

        .progress-fill {
            height: 100%;
            background: linear-gradient(to right, #4facfe 0%, #00f2fe 100%);
            border-radius: 10px;
            transition: width 0.5s ease;
        }

        .progress-text {
            font-weight: 600;
            font-size: 1.1rem;
            min-width: 100px;
            text-align: center;
            color: #4776E6;
        }

        .add-task {
            padding: 20px;
            display: flex;
            background-color: #f8f9fa;
            border-bottom: 1px solid #e0e0e0;
        }

        .add-task input {
            flex-grow: 1;
            padding: 15px;
            border: 2px solid #e0e0e0;
            border-radius: 8px 0 0 8px;
            font-size: 1.1rem;
            outline: none;
            transition: border-color 0.3s;
        }

        .add-task input:focus {
            border-color: #4776E6;
        }

        .add-task button {
            background: linear-gradient(to right, #4776E6, #8E54E9);
            color: white;
            border: none;
            padding: 0 30px;
            border-radius: 0 8px 8px 0;
            font-size: 1.1rem;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s;
        }

        .add-task button:hover {
            opacity: 0.9;
            transform: translateY(-2px);
        }

        .tasks-container {
            padding: 20px;
            max-height: 400px;
            overflow-y: auto;
        }

        .task-list {
            list-style: none;
        }

        .task-item {
            display: flex;
            align-items: center;
            padding: 15px;
            background-color: white;
            border-radius: 10px;
            margin-bottom: 15px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
            transition: all 0.3s;
            border-left: 4px solid #4776E6;
        }

        .task-item:hover {
            transform: translateY(-3px);
            box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
        }

        .task-item.completed {
            background-color: #f8f9fa;
            border-left-color: #4CAF50;
            opacity: 0.8;
        }

        .task-item.completed .task-text {
            text-decoration: line-through;
            color: #777;
        }

        .task-checkbox {
            margin-right: 15px;
            width: 22px;
            height: 22px;
            cursor: pointer;
            accent-color: #4CAF50;
        }

        .task-text {
            flex-grow: 1;
            font-size: 1.2rem;
            color: #333;
        }

        .task-actions {
            display: flex;
            gap: 10px;
        }

        .task-actions button {
            background: none;
            border: none;
            cursor: pointer;
            font-size: 1.1rem;
            width: 36px;
            height: 36px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s;
        }

        .edit-btn {
            color: #FFC107;
        }

        .edit-btn:hover {
            background-color: #FFF9C4;
        }

        .delete-btn {
            color: #F44336;
        }

        .delete-btn:hover {
            background-color: #FFEBEE;
        }

        .empty-state {
            text-align: center;
            padding: 40px 20px;
            color: #777;
        }

        .empty-state i {
            font-size: 4rem;
            margin-bottom: 20px;
            color: #e0e0e0;
        }

        .empty-state h3 {
            font-size: 1.5rem;
            margin-bottom: 10px;
        }

        .stats {
            display: flex;
            justify-content: space-around;
            padding: 20px;
            background-color: #f8f9fa;
            border-top: 1px solid #e0e0e0;
        }

        .stat-box {
            text-align: center;
            padding: 15px;
        }

        .stat-box h3 {
            font-size: 2rem;
            color: #4776E6;
            margin-bottom: 5px;
        }

        .stat-box p {
            color: #666;
            font-size: 0.9rem;
        }

        /* 响应式设计 */
        @media (max-width: 600px) {
            .header h1 {
                font-size: 2rem;
            }
            
            .add-task {
                flex-direction: column;
                gap: 10px;
            }
            
            .add-task input {
                border-radius: 8px;
            }
            
            .add-task button {
                border-radius: 8px;
                padding: 15px;
            }
            
            .progress-container {
                flex-direction: column;
                gap: 10px;
            }
            
            .progress-bar {
                width: 100%;
                margin: 10px 0;
            }
            
            .stats {
                flex-direction: column;
                gap: 10px;
            }
        }

        .task-input {
            position: relative;
            flex-grow: 1;
        }

        .task-input input {
            width: 100%;
            padding: 15px 15px 15px 45px;
        }

        .task-input i {
            position: absolute;
            left: 15px;
            top: 50%;
            transform: translateY(-50%);
            color: #888;
        }

        .footer {
            text-align: center;
            padding: 20px;
            color: #777;
            font-size: 0.9rem;
            border-top: 1px solid #e0e0e0;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1><i class="fas fa-tasks"></i> 每日任务追踪器</h1>
            <p>规划你的一天，提高工作效率</p>
        </div>
        
        <div class="progress-container">
            <div class="progress-text">今日进度</div>
            <div class="progress-bar">
                <div class="progress-fill" id="progress-fill" style="width: 25%;"></div>
            </div>
            <div class="progress-text" id="progress-text">25%</div>
        </div>
        
        <div class="add-task">
            <div class="task-input">
                <i class="fas fa-plus"></i>
                <input type="text" id="task-input" placeholder="添加新任务...">
            </div>
            <button id="add-task-btn"><i class="fas fa-plus"></i> 添加任务</button>
        </div>
        
        <div class="tasks-container">
            <ul class="task-list" id="task-list">
                <!-- 任务会动态添加到这里 -->
            </ul>
            
            <div class="empty-state" id="empty-state">
                <i class="fas fa-check-circle"></i>
                <h3>没有待办任务</h3>
                <p>添加新任务开始你的一天！</p>
            </div>
        </div>
        
        <div class="stats">
            <div class="stat-box">
                <h3 id="total-tasks">0</h3>
                <p>总任务</p>
            </div>
            <div class="stat-box">
                <h3 id="completed-tasks">0</h3>
                <p>已完成</p>
            </div>
            <div class="stat-box">
                <h3 id="pending-tasks">0</h3>
                <p>待完成</p>
            </div>
        </div>
        
        <div class="footer">
            <p>每天完成小目标，成就大梦想！</p>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // DOM元素
            const taskInput = document.getElementById('task-input');
            const addTaskBtn = document.getElementById('add-task-btn');
            const taskList = document.getElementById('task-list');
            const emptyState = document.getElementById('empty-state');
            const progressFill = document.getElementById('progress-fill');
            const progressText = document.getElementById('progress-text');
            const totalTasksEl = document.getElementById('total-tasks');
            const completedTasksEl = document.getElementById('completed-tasks');
            const pendingTasksEl = document.getElementById('pending-tasks');
            
            // 任务数组
            let tasks = JSON.parse(localStorage.getItem('tasks')) || [];
            
            // 初始化
            renderTasks();
            updateStats();
            
            // 添加任务
            addTaskBtn.addEventListener('click', addTask);
            taskInput.addEventListener('keypress', function(e) {
                if (e.key === 'Enter') {
                    addTask();
                }
            });
            
            function addTask() {
                const taskText = taskInput.value.trim();
                if (taskText === '') return;
                
                const newTask = {
                    id: Date.now(),
                    text: taskText,
                    completed: false,
                    createdAt: new Date().toISOString()
                };
                
                tasks.push(newTask);
                saveTasks();
                renderTasks();
                updateStats();
                
                taskInput.value = '';
                taskInput.focus();
            }
            
            // 渲染任务列表
            function renderTasks() {
                if (tasks.length === 0) {
                    emptyState.style.display = 'block';
                    taskList.innerHTML = '';
                    return;
                }
                
                emptyState.style.display = 'none';
                taskList.innerHTML = '';
                
                tasks.forEach(task => {
                    const taskItem = document.createElement('li');
                    taskItem.className = `task-item ${task.completed ? 'completed' : ''}`;
                    taskItem.dataset.id = task.id;
                    
                    taskItem.innerHTML = `
                        <input type="checkbox" class="task-checkbox" ${task.completed ? 'checked' : ''}>
                        <span class="task-text">${task.text}</span>
                        <div class="task-actions">
                            <button class="edit-btn"><i class="fas fa-edit"></i></button>
                            <button class="delete-btn"><i class="fas fa-trash-alt"></i></button>
                        </div>
                    `;
                    
                    taskList.appendChild(taskItem);
                    
                    // 添加事件监听器
                    const checkbox = taskItem.querySelector('.task-checkbox');
                    const editBtn = taskItem.querySelector('.edit-btn');
                    const deleteBtn = taskItem.querySelector('.delete-btn');
                    
                    checkbox.addEventListener('change', function() {
                        toggleTaskCompleted(task.id);
                    });
                    
                    editBtn.addEventListener('click', function() {
                        editTask(task.id);
                    });
                    
                    deleteBtn.addEventListener('click', function() {
                        deleteTask(task.id);
                    });
                });
            }
            
            // 切换任务完成状态
            function toggleTaskCompleted(taskId) {
                tasks = tasks.map(task => {
                    if (task.id === taskId) {
                        return { ...task, completed: !task.completed };
                    }
                    return task;
                });
                
                saveTasks();
                updateStats();
            }
            
            // 编辑任务
            function editTask(taskId) {
                const task = tasks.find(t => t.id === taskId);
                const newText = prompt('编辑任务', task.text);
                
                if (newText !== null && newText.trim() !== '') {
                    tasks = tasks.map(t => {
                        if (t.id === taskId) {
                            return { ...t, text: newText.trim() };
                        }
                        return t;
                    });
                    
                    saveTasks();
                    renderTasks();
                }
            }
            
            // 删除任务
            function deleteTask(taskId) {
                if (confirm('确定要删除这个任务吗？')) {
                    tasks = tasks.filter(task => task.id !== taskId);
                    saveTasks();
                    renderTasks();
                    updateStats();
                }
            }
            
            // 更新统计信息
            function updateStats() {
                const totalTasks = tasks.length;
                const completedTasks = tasks.filter(task => task.completed).length;
                const pendingTasks = totalTasks - completedTasks;
                const progress = totalTasks > 0 ? Math.round((completedTasks / totalTasks) * 100) : 0;
                
                totalTasksEl.textContent = totalTasks;
                completedTasksEl.textContent = completedTasks;
                pendingTasksEl.textContent = pendingTasks;
                
                progressFill.style.width = `${progress}%`;
                progressText.textContent = `${progress}%`;
            }
            
            // 保存任务到本地存储
            function saveTasks() {
                localStorage.setItem('tasks', JSON.stringify(tasks));
            }
        });
    </script>
</body>
</html>